package com.example.demo.controller;

import com.example.demo.mapper.BookSaleMapper;
import com.example.demo.pojo.BookSale;
import com.example.demo.service.BookSaleService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author bzh
 * 🤪回来吧我的Java👈🏻🤣
 * Create Time:2023/5/20 11:47
 */
@CrossOrigin
@RestController
@RequestMapping("/book")
public class BookSaleController {

    private BookSaleService saleService;
    private BookSaleMapper saleMapper;

    public BookSaleController(BookSaleService saleService, BookSaleMapper saleMapper) {
        this.saleService = saleService;
        this.saleMapper = saleMapper;
    }

    @GetMapping("/sale")
    @Cacheable(cacheNames = "BookSale")
    public List<BookSale> getData(){

        List<BookSale> list = saleMapper.getList();
        return list;
    }


}
